/*
 * Copyright (c) 2019. Lorem ipsum dolor sit amet, consectetur adipiscing elit.
 * Morbi non lorem porttitor neque feugiat blandit. Ut vitae ipsum eget quam lacinia accumsan.
 * Etiam sed turpis ac ipsum condimentum fringilla. Maecenas magna.
 * Proin dapibus sapien vel ante. Aliquam erat volutpat. Pellentesque sagittis ligula eget metus.
 * Vestibulum commodo. Ut rhoncus gravida arcu.
 */

package com.evenmo.string;


import java.util.Objects;

/**
 * This is Description
 *
 * @author moyongjun
 * @date 2019/12/07
 */
public class Student implements Comparable<Student>{

    private Integer id;
    private String name;
    private Integer sex;
    private Boolean flag;

    public Student(){

    }

    public Student(Integer id, String name, Integer sex, Boolean flag) {
        super();
        this.id = id;
        this.name = name;
        this.sex = sex;
        this.flag = flag;
    }

    public Integer getId() {
        return id;
    }

    public void setId(Integer id) {
        this.id = id;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public Integer getSex() {
        return sex;
    }

    public void setSex(Integer sex) {
        this.sex = sex;
    }

    public Boolean getFlag() {
        return flag;
    }

    public void setFlag(Boolean flag) {
        this.flag = flag;
    }

 public String toString(){
        return "Student[id="+getId()+" name="+getName()+" sex="+getSex()+" flag="+getFlag()+"]";
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;
        Student student = (Student) o;
        return id.equals(student.id) &&
                name.equals(student.name) &&
                sex.equals(student.sex) &&
                flag.equals(student.flag);
    }

    @Override
    public int hashCode() {
        return Objects.hash(id, name, sex, flag);
    }


    @Override
    public int compareTo(Student o) {
//当前对象和其他对象比较，从小到大
        int i=this.getId()-o.getId();
        int j=i==0?this.getName().compareTo(o.getName()):i;
        return j;
    }

}
